import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import parse from '@dfeidao/atom-web/dt/parse';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import format from '@dfeidao/atom-web/dt/format';
import render from '@dfeidao/atom-web/render/render';
import p004 from './p004';
import p005 from './p005';
import p007 from './p007';
import get from '@dfeidao/atom-web/global/get';
interface Par extends Event {
	page_no: number;
}
export default async function a012(fd: IFeidaoAiBrowserComponent,e:Par) {
	// todo
	const staff_no = get('staff_no');
	const n = fd.data.node.querySelector<HTMLInputElement>('[data-id="conference_theme1"]').value;
	// 时间格式
	const ch_sj = fd.data.node.querySelector<HTMLDataElement>('[data-id="ch"]').value;
	const ks = parse(ch_sj);
	const js_sj = fd.data.node.querySelector<HTMLDataElement>('[data-id="ch1"]').value;
	const js = parse(js_sj);
	if (ks > js) {
		alert('开始时间不能大于结束时间');
		return;
	}
	if (ch_sj === '' || js_sj === '') {
		alert('请选择时间段');
		return;
	}
	const res = await nodejs<{ res: Array<{ meeting_no: string, meeting_name: string, start_time: number, conference_theme: string, meeting_status: string, sponsor: string, meeting_address: string }>; s: Array<{}> }>('meeting-management/zj-000001/s006', {
		staff_no,
		conference_theme: n,
		start_time: ks,
		start_time1: js,
		pn:e.page_no
	});
	// tslint:disable-next-line:no-shadowed-variable
	const d = res.res.map((n) => {
		// 0 不显示时分秒 1 显示秒  2 不显示秒
		return { ...n, start_time: format(n.start_time, 0) };
	});

	if (res.s.length > 0) {
		render(fd, d, p004, 'p004', 'inner');

	} else {
		render(fd, '', p005, 'p005', 'inner');

	}


}
